package com.yuanchu.goods.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuanchu.goods.entity.YoshopGoodsSkuEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 商品规格表
 * 
 * @author adan
 * @email 2028038953@gmail.com
 * @date 2023-12-19 02:17:43
 */
@Mapper
public interface YoshopGoodsSkuDao extends BaseMapper<YoshopGoodsSkuEntity> {

    @Update("update yoshop_goods_sku set stock_num = yoshop_goods_sku.stock_num - #{stockNum}\n" +
            "                        where goods_id = #{goodsId} and goods_sku_id = #{goodsSkuId}\n" +
            "and yoshop_goods_sku.stock_num > #{stockNum}")
    Integer updateGoodsSkuStockNum(@Param("goodsId")Integer goodsId,
                                   @Param("goodsSkuId") String goodsSkuId,
                                   @Param("stockNum") Integer stockNum);

}
